# -*- coding: utf-8 -*-

'''
   Copyright (c) 2023. China Mobile(SuZhou)Software Technology Co.,Ltd. All rights reserved.
   secScanner is licensed under Mulan PSL v2.
   You can use this software according to the terms and conditions of the Mulan PSL v2.
   You may obtain a copy of Mulan PSL v2 at:
            http://license.coscl.org.cn/MulanPSL2
   THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 
   EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 
   MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
   See the Mulan PSL v2 for more details.
'''


import logging
from secScanner.lib import *
from secScanner.commands.check_outprint import *
logger = logging.getLogger("secscanner")

def C21_issueRemove():
    InsertSection("check the issue file")
    ISVIRTUALMACHINE = get_value("ISVIRTUALMACHINE")
    if ISVIRTUALMACHINE != 1:
        if os.path.exists("/etc/issue") and os.path.exists("/etc/issue.net"):
            with open(RESULT_FILE, "a") as file:
                file.write("\nC21\n")
            logger.warning("WRN_C21 :%s", WRN_C21)
            logger.warning("SUG_C21: %s", SUG_C21)
            Display("- Check if there is issue file...", "WARNING")
        else:
            logger.info("There is no issue file remain, check ok")
            Display("- Check if there is issue file...", "OK")
    else:
        logger.info("This is virtual machine, can't remove the issue file")
        Display("- This is virtual machine, can't remove the issue file", 'SKIPPED')




